<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Log_balance
{
	private $ci;
	
	public function __construct()
	{
		$this->ci = & get_instance();
		$this->ci->load->helper('transaction');
	}
	
	/**
	 * add log amount
	 * 
	 * @param int $userId
	 * @param int $amount
	 * @param int $balance
	 * @param tinyint $status, 1: tăng,2: giảm
	 */
	public function addLogAmount($userId, $amount, $balance, $status)
	{
		$this->ci->load->model('log_amount_model');
		
		$insertData = array(
			'user_id' => $userId,
			'status' => $status,
			'score' => $amount,
			'balance' => $balance,
			'created' => time()
		);
		
		return $this->ci->log_amount_model->addLogAmount($insertData);
	}
	
	/**
	 * add log frozen
	 *
	 * @param int $userId
	 * @param int $frozen
	 * @param int $balance
	 * @param tinyint $status, 1: tăng,2: giảm
	 */
	public function addLogFrozen($userId, $frozen, $balance, $status)
	{
		$this->ci->load->model('log_frozen_model');
	
		$insertData = array(
				'user_id' => $userId,
				'status' => $status,
				'score' => $frozen,
				'balance' => $balance,
				'created' => time()
		);
	
		return $this->ci->log_frozen_model->addLogFrozen($insertData);
	}

    public function addLogExperience($userId, $experience, $balance, $status)
    {
        $this->ci->load->model('log_experience_model');

        $insertData = array(
            'user_id' => $userId,
            'status' => $status,
            'score' => $experience,
            'balance' => $balance,
            'created' => time()
        );

        return $this->ci->log_experience_model->addLogExperience($insertData);
    }

    public function addLogBonus($userId, $bonus, $balance, $status)
    {
        $this->ci->load->model('log_bonus_model');

        $insertData = array(
            'user_id' => $userId,
            'status' => $status,
            'score' => $bonus,
            'balance' => $balance,
            'created' => time()
        );

        return $this->ci->log_bonus_model->addLogBonus($insertData);
    }


}	
